﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <el-form ref="formRefProdTransSn" :model="stateProdTransSn.vmModel" label-width="100px">
    <div style="margin-bottom:10px;">{{$t('message.autotrans.SysBatchEditConfirm')}}</div>
    <el-row>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_Sn_FormItem" prop="LinkedVM.Sn" :label="$t('message.autotrans._Model_ProdTransSn_Sn')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_ProdTransSn_Sn')}), trigger: 'blur' }]" >
          <el-input v-model="stateProdTransSn.vmModel.LinkedVM.Sn" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_ProductId_FormItem" prop="LinkedVM.ProductId" :label="$t('message.autotrans._Model_ProdTransSn_ProductId')">
          <el-input v-model="stateProdTransSn.vmModel.LinkedVM.ProductId" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_ProductCode_FormItem" prop="LinkedVM.ProductCode" :label="$t('message.autotrans._Model_ProdTransSn_ProductCode')">
          <el-input v-model="stateProdTransSn.vmModel.LinkedVM.ProductCode" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_Wo_FormItem" prop="LinkedVM.Wo" :label="$t('message.autotrans._Model_ProdTransSn_Wo')">
          <el-input v-model="stateProdTransSn.vmModel.LinkedVM.Wo" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_CurLineId_FormItem" prop="LinkedVM.CurLineId" :label="$t('message.autotrans._Model_ProdTransSn_CurLineId')">
          <el-input v-model="stateProdTransSn.vmModel.LinkedVM.CurLineId" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_CurLineCode_FormItem" prop="LinkedVM.CurLineCode" :label="$t('message.autotrans._Model_ProdTransSn_CurLineCode')">
          <el-input v-model="stateProdTransSn.vmModel.LinkedVM.CurLineCode" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_CurOpId_FormItem" prop="LinkedVM.CurOpId" :label="$t('message.autotrans._Model_ProdTransSn_CurOpId')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_ProdTransSn_CurOpId')}), trigger: 'blur' }]" >
          <el-input v-model="stateProdTransSn.vmModel.LinkedVM.CurOpId" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_CurOpCode_FormItem" prop="LinkedVM.CurOpCode" :label="$t('message.autotrans._Model_ProdTransSn_CurOpCode')">
          <el-input v-model="stateProdTransSn.vmModel.LinkedVM.CurOpCode" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_CurRoutingId_FormItem" prop="LinkedVM.CurRoutingId" :label="$t('message.autotrans._Model_ProdTransSn_CurRoutingId')">
          <el-input v-model="stateProdTransSn.vmModel.LinkedVM.CurRoutingId" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_CurRoutingCode_FormItem" prop="LinkedVM.CurRoutingCode" :label="$t('message.autotrans._Model_ProdTransSn_CurRoutingCode')">
          <el-input v-model="stateProdTransSn.vmModel.LinkedVM.CurRoutingCode" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_InboundTime_FormItem" prop="LinkedVM.InboundTime" :label="$t('message.autotrans._Model_ProdTransSn_InboundTime')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_ProdTransSn_InboundTime')}), trigger: 'blur' }]" >
          <el-date-picker v-model="stateProdTransSn.vmModel.LinkedVM.InboundTime" type='date' clearable></el-date-picker>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_OutboundTime_FormItem" prop="LinkedVM.OutboundTime" :label="$t('message.autotrans._Model_ProdTransSn_OutboundTime')">
          <el-date-picker v-model="stateProdTransSn.vmModel.LinkedVM.OutboundTime" type='date' clearable></el-date-picker>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_OnlineTime_FormItem" prop="LinkedVM.OnlineTime" :label="$t('message.autotrans._Model_ProdTransSn_OnlineTime')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_ProdTransSn_OnlineTime')}), trigger: 'blur' }]" >
          <el-date-picker v-model="stateProdTransSn.vmModel.LinkedVM.OnlineTime" type='date' clearable></el-date-picker>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_OfflineTime_FormItem" prop="LinkedVM.OfflineTime" :label="$t('message.autotrans._Model_ProdTransSn_OfflineTime')">
          <el-date-picker v-model="stateProdTransSn.vmModel.LinkedVM.OfflineTime" type='date' clearable></el-date-picker>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_Stage_FormItem" prop="LinkedVM.Stage" :label="$t('message.autotrans._Model_ProdTransSn_Stage')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_ProdTransSn_Stage')}), trigger: 'blur' }]" >
          <el-select v-model="stateProdTransSn.vmModel.LinkedVM.Stage" clearable>
             <el-option key="Inbound" value="Inbound" :label="$t('message.autotrans._Enum_SnStageEnum_Inbound')"></el-option>
             <el-option key="Outbound" value="Outbound" :label="$t('message.autotrans._Enum_SnStageEnum_Outbound')"></el-option>
          </el-select>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_Status_FormItem" prop="LinkedVM.Status" :label="$t('message.autotrans._Model_ProdTransSn_Status')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_ProdTransSn_Status')}), trigger: 'blur' }]" >
          <el-select v-model="stateProdTransSn.vmModel.LinkedVM.Status" clearable>
             <el-option key="OK" value="OK" :label="$t('message.autotrans._Enum_SnStatusEnum_OK')"></el-option>
             <el-option key="NG" value="NG" :label="$t('message.autotrans._Enum_SnStatusEnum_NG')"></el-option>
             <el-option key="MandatoryOK" value="MandatoryOK" :label="$t('message.autotrans._Enum_SnStatusEnum_MandatoryOK')"></el-option>
             <el-option key="MandatoryNG" value="MandatoryNG" :label="$t('message.autotrans._Enum_SnStatusEnum_MandatoryNG')"></el-option>
             <el-option key="Scrap" value="Scrap" :label="$t('message.autotrans._Enum_SnStatusEnum_Scrap')"></el-option>
          </el-select>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_IsCompelted_FormItem" prop="LinkedVM.IsCompelted" :label="$t('message.autotrans._Model_ProdTransSn_IsCompelted')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_ProdTransSn_IsCompelted')}), trigger: 'blur' }]" >
          <el-switch v-model="stateProdTransSn.vmModel.LinkedVM.IsCompelted" clearable></el-switch>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_CustomerSn_FormItem" prop="LinkedVM.CustomerSn" :label="$t('message.autotrans._Model_ProdTransSn_CustomerSn')">
          <el-input v-model="stateProdTransSn.vmModel.LinkedVM.CustomerSn" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_ReworkFlag_FormItem" prop="LinkedVM.ReworkFlag" :label="$t('message.autotrans._Model_ProdTransSn_ReworkFlag')">
          <el-select v-model="stateProdTransSn.vmModel.LinkedVM.ReworkFlag" clearable>
             <el-option key="None" value="None" :label="$t('message.autotrans._Enum_ReworkFlagEnum_None')"></el-option>
             <el-option key="Wait" value="Wait" :label="$t('message.autotrans._Enum_ReworkFlagEnum_Wait')"></el-option>
             <el-option key="Working" value="Working" :label="$t('message.autotrans._Enum_ReworkFlagEnum_Working')"></el-option>
             <el-option key="Done" value="Done" :label="$t('message.autotrans._Enum_ReworkFlagEnum_Done')"></el-option>
             <el-option key="DoneAndWaitToRelaunch" value="DoneAndWaitToRelaunch" :label="$t('message.autotrans._Enum_ReworkFlagEnum_DoneAndWaitToRelaunch')"></el-option>
          </el-select>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_ReworkDoc_FormItem" prop="LinkedVM.ReworkDoc" :label="$t('message.autotrans._Model_ProdTransSn_ReworkDoc')">
          <el-input v-model="stateProdTransSn.vmModel.LinkedVM.ReworkDoc" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_ReworkCount_FormItem" prop="LinkedVM.ReworkCount" :label="$t('message.autotrans._Model_ProdTransSn_ReworkCount')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_ProdTransSn_ReworkCount')}), trigger: 'blur' }]" >
          <el-input v-model="stateProdTransSn.vmModel.LinkedVM.ReworkCount" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_NgSteps_FormItem" prop="LinkedVM.NgSteps" :label="$t('message.autotrans._Model_ProdTransSn_NgSteps')">
          <el-input v-model="stateProdTransSn.vmModel.LinkedVM.NgSteps" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_IsNeedRework_FormItem" prop="LinkedVM.IsNeedRework" :label="$t('message.autotrans._Model_ProdTransSn_IsNeedRework')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_ProdTransSn_IsNeedRework')}), trigger: 'blur' }]" >
          <el-switch v-model="stateProdTransSn.vmModel.LinkedVM.IsNeedRework" clearable></el-switch>
      </el-form-item>

      </el-col>
    </el-row>

    <div style="text-align:right;">
      <WtmButton @click="onSubmitProdTransSn"  type="primary" :button-text="$t('message.autotrans.SysSubmit')" style="margin-top:15px;"/>

      <WtmButton @click="onCloseProdTransSn"  type="primary" :button-text="$t('message.autotrans.SysClose')" style="margin-top:15px;"/>

    </div>

  </el-form>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageProductionManagementProdTransSnBatchEdit;false">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { prodtranssnApi } from '/@/api/productionmanagement/prodtranssn';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;


// 定义变量内容
const formRefProdTransSn = ref();
const stateProdTransSn = reactive({
    vmModel: {
	  LinkedVM:{
        Sn: '',
        ProductCode: '',
        Wo: '',
        CurLineCode: '',
        CurOpCode: '',
        CurRoutingCode: '',
        InboundTime: undefined,
        OutboundTime: undefined,
        OnlineTime: undefined,
        OfflineTime: undefined,
        Stage: undefined,
        Status: undefined,
        IsCompelted: undefined,
        CustomerSn: '',
        ReworkFlag: undefined,
        ReworkDoc: '',
        NgSteps: '',
        IsNeedRework: undefined,
      },
      Ids:[],
      
	},
    
});

// 取消
const onCloseProdTransSn = () => {
    closeDialog();
};

// 提交
const onSubmitProdTransSn = () => {
	const loadingInstance = ElLoading.service({
		lock: true,
		text: '正在提交中，请等待。。。',
		background: 'rgba(0, 0, 0, 0.7)',
	});

    formRefProdTransSn.value?.validate((valid: boolean, fields: any) => {
		if (valid) {
            prodtranssnApi().batchedit(stateProdTransSn.vmModel).then(() => {
                ElMessage.success(ci.proxy.$t('message._system.common.vm.submittip'));
                emit('refresh');
                closeDialog();
            }).catch((error:any) => {
                other.setFormError(ci, error);
            }).finally(() => {
			loadingInstance.close();
		    })
		}
        else{
			loadingInstance.close();
        }
	})
};


// 页面加载时
onMounted(() => {
    
    if (ci.attrs["wtmdata"]) {
		stateProdTransSn.vmModel.Ids = ci.attrs["wtmdata"];
	}
	else if (useRouter().currentRoute.value.query.id) {
		stateProdTransSn.vmModel.Ids = useRouter().currentRoute.value.query.id as any;
	}

});

// 定义子组件向父组件传值/事件
const emit = defineEmits(['refresh','closeDialog']);
// 关闭弹窗
const closeDialog = () => {
    emit('closeDialog');
};
// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

